1. Field of the Invention
The present invention relates to a storage device which, upon receipt of an emergency evacuation command based on an impact prediction or the like, causes a head to evacuate from a medium, a control method thereof and a program. More particularly, the invention relates to a storage device, a control method thereof and a program for causing a head to evacuate by an emergency evacuation command during execution of a queued input/output command.
2. Description of the Related Art
In a storage device such as a magnetic disk apparatus, it is the conventional practice to provide a ramp mechanism which holds the head by causing the head to evacuate from the medium in stoppage of the device, to perform a loading processing to shake out the head from the ramp mechanism onto the medium when rotation of the medium caused by activation of the device reaches a certain number of revolutions, and to conduct an unloading processing in which the head is caused to evacuate from the medium into the ramp mechanism upon stoppage of the device. A high-speed serial transfer interface such as a serial ATA (ANSI T13/Serial ATA International Organization (SATA-IO)) is used in a more recent storage device as an interface with the host. In such an interface, a command queuing function which executes an input/output command (a write command or a read command) issued by a host through queuing (called “Native Command Queuing” in serial ATA) is provided to reduce the processing time (overhead) of the upper device and the magnetic disk apparatus. The command queuing function provided by a high-speed serial transfer interface comprises the steps of storing input/output commands from the host into a queue of the magnetic disk apparatus in the order of command issuance (out-order), performing a reordering of arranging the commands in the increasing order of access time on the device side, taking out the commands in the order of arrangement and sequentially executing them, and upon the completion of command execution, notifying the host of the end status in the order of command completion. That is, the command queuing function queues input/output commands from the host “in-order” (order of issuance), then conducts a reorder of arranging the commands in the increasing order of medium access time to execute the commands “out-order”, and upon the completion of command execution, responds the command completion as they are in the “out-order” state. Even in a magnetic disk apparatus using a parallel transfer interface in use prior to the recent general use of the high-speed serial transfer interface, this command queuing function of input/output commands in a storage device is now industrially applied, not as an interface, but as a function on the device side. However, the command queuing function provided as a function on the device side in the conventional art is the same as above in that input/output commands from the host are queued in the sequence of issuance and arranged in the increasing order of access time for execution. For the end response to the host upon the completion of command execution, however, the command end is responded in the order of command issuance since the host is not conscious of the command queuing function on the device side. In other words, in the conventional command queuing function working only on the device side, input/output commands from the host are queued “in-order” (in the command issuing order), then, reordering is carried out in the increasing order of medium access time in arrangement to execute the commands “out-order”, and upon the completion of command execution, the end of commands is reported to the host “in-order” (in the order of command issuance). Even when the command queuing function is provided on the device side, therefore, the command end response to the host is conducted in the order of command issuance before reordering. Even if command execution is completed on the device side, the command end response must wait for the completion of response of execution completion of all preceding commands issued by the host. Provision of the command queuing function on the device side brings about no difference in the processing time as viewed from the host from the case of absence of the command queuing function, leading to a problem in that the provision makes no contribution to the reduction of the processing time between the host and the device. The above-mentioned problem is solved by the command queuing function provided by the high-speed serial transfer interface. Upon completion of command execution “out-order” by reordering on the device side, a command end response can be immediately given to the host while holding the “out-order” state, thus enabling to directly reflect the reduction of the processing time achieved by reordering on the device side in the reduction of the processing time between the host and the device. Furthermore, in the control procedure of command queuing in the conventional high-speed serial transfer interface, i.e., in the command queuing protocol, when the host issues an input/output command to be queued, the storage device keeps its queuing state until the command ends normally or in error and the command end is reported to the host in response “out-order”. To maintain this protocol, the host is prohibited from issuing any command other than the input/output commands to be queued in the command queuing state by the protocol. On the other hand, in a recent portable information processing device such as a lap-top type personal computer, for the purpose of preventing breakage of the storage device caused by a falling impact of the device, a protection control is proposed in which a sensor detecting an inclination or vibration is provided on the host side. Falling is predicted from a sensor detection signal and an emergency evacuation command is issued to the storage device, thus causing the head to emergency-evacuate from the medium to the ramp mechanism before suffering from the impact (see Nos. JP2004-171608 and 2004-146036). However, when the host and the storage device are connected via a high-speed serial transfer interface providing the command queuing function, if command queuing is in a non-activated state in which an input/output command is not stored in the queue on the device side, it is possible to cause the head to evacuate from the medium into the ramp mechanism by executing an emergency evacuation command from the host. However, when the host issues an emergency evacuation command in the activated state of command queuing, the storage device interprets it as a protocol error since the storage device is generally worked out into a commercial product in accordance with the rules of command queuing protocol between a host and a device. There is therefore a problem in that the storage device only reports the error and does not execute the emergency evacuation command, and the head cannot emergency-evacuate from the medium into the ramp mechanism.